/*
	Application is a class that sets up basic timing, handles some gl code, and a lot of other things.




*/

#pragma once
#include <gl/glew.h>
#define NO_SDL_GLEXT //we want to use glew for extensions, not sdl.
#include <SDL.h>
#include "SDL_opengl.h"


#include "Input.h"
#include "Font.h"
#include "Color.h"
#include "Rectangle.h"
#include "Image.h"
#include "World.h"
#include "Constants.h"
#include "CollisionObject.h"
#include "Shader.h"
#include "ParticleSystem.h"
#include "Random.h"
#include "Graphics3D.h"

class Application
{
private:
	static const int TICKS_PER_SECOND = 60;
    static const int SKIP_TICKS = 1000 / TICKS_PER_SECOND;
    static const int MAX_FRAMESKIP = 5;
	int counter, oldTime; //FPS stuff
	unsigned long nextGameTick;
	Font* currentFont;
	Font* defaultFont;
	int screenWidth, screenHeight;

	void runApp();
	void createWindow(int width, int height, std::string title);


protected:
	bool runApplication;
	int renderFPS; //FPS stuff

	virtual void update();
	virtual void render(float interpolation);

	void enable2D();
	void disable2D();
	unsigned long getTime();
	void clear();

	void drawText(int x, int y, std::string text);
	void drawText(int x, int y, int);
	void drawText(int x, int y, float);
	void setFont(Font* font);

public:
	Application(int width, int height, std::string title);
	~Application(void);

	void run();
	int getScreenWidth();
	int getScreenHeight();

	void setWindowTitle(std::string title);

};
